﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CommandLib.Base;

namespace My12306
{
    public partial class FrmConfirm : Form
    {
       
        private FrmMain frmMain;
        public bool IsCancel;
        public FrmConfirm()
        {
            InitializeComponent();
        }
        public FrmConfirm(FrmMain frmMain)
        {
            InitializeComponent();
            this.frmMain = frmMain;
            this.chkSend100.Enabled = true;
            this.RefreshCheckCode();
        }

        private void RefreshCheckCode()
        {
            try
            {
                Random random = new Random();
                this.picCheckCode.Image = this.frmMain.http.Getimg("https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=randp&" + random.NextDouble(), "image/png,image/*;q=0.8,*/*;q=0.5");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Log.WriteLog4Ex("RefreshCheckCode", ex);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtCheckCode.Text))
            {
                MessageBox.Show("验证码必须输入!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                base.Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.IsCancel = true;
            base.Close();
        }

        private void picCheckCode_Click(object sender, EventArgs e)
        {
            this.RefreshCheckCode();
        }
    }
}
